#include "tablechange.h"

TableChange::TableChange(int newRev, int newUser, int newDoc, int newPos, int newRows, int newCols) :
        Change(Message::ADD_TABLE, newRev, newUser, newDoc, newPos)
{
    rows = newRows;
    cols = newCols;
}

TableChange::TableChange(QByteArray bytes)
{
    operation = Message::ADD_TABLE;

    QDataStream sin(bytes);

    //get the operation
    quint8 op;
    sin >> op;
    operation = op;

    sin >> revisionId >> userId >> docId >> position >> rows >> cols;
}

QByteArray TableChange::toBytes()
{
    QByteArray bytes;
    QDataStream sout(&bytes, QIODevice::WriteOnly);

    sout << operation << revisionId << userId << docId << position << rows << cols;

    return bytes;
}
